
import baseRequest from '../utils/requset'

// 我的订单
// /myOrderList/{pageNum}/{pageSize}

export function getMyOrderListApi (pageNum,pageSize,data) {
    return baseRequest.baseRequest(`api/order/myOrderList/${pageNum}/${pageSize}`, 'get', data)
}


// /api/order/payment/status/{orderId}  查询订单支付状态 
// /订单支付结果查询
export function getOrderPaymentStatusApi (orderId) {
    return baseRequest.baseRequest(`api/order/payment/status/${orderId}`, 'get')
}

// 订单详情 /api/order/detail/{orderId}
export function getOrderDetailApi (orderId) {
    return baseRequest.baseRequest(`api/order/detail/${orderId}`, 'get')
}

// 删除订单 /api/order/delete/{orderId}  post
export function deleteOrderApi (orderId) {
    return baseRequest.baseRequest(`api/order/delete/${orderId}`, 'post')
}
// 取消订单/api/order/cancel/{xxxx}?cancelType=xxxx    post请求  reasonType 取消原因类型
export function cancelOrderApi (orderId,cancelType) {
    // 规定时间内未支付 则不传reasonType  否则其他取消订单情况传reasonType
    let url = `api/order/cancel/${orderId}`;
    if (cancelType !== undefined && cancelType !== null) {
        url += `?cancelType=${cancelType}`;
    }
    return baseRequest.baseRequest(url, 'post')
}

// 修改地址/api/order/modify/address/{orderId}/{addressId}  post    订单修改收货地址
export function modifyOrderAddressApi (orderId,addressId) {
    return baseRequest.baseRequest(`api/order/modify/address/${orderId}/${addressId}`, 'post')
}


// 查看物流
export function getOrderLogisticsApi (orderId) {
    return baseRequest.baseRequest(`api/order/logistics/${orderId}`, 'get')
}



// 再次购买/api/miniProgram/shoppingCart/batchAddToShoppingCart
export function batchAddToShoppingCartApi (data) {
    return baseRequest.baseRequest('api/miniProgram/shoppingCart/batchAddToShoppingCart', 'post', JSON.stringify(data))
}


//确认收货 /api/order/confirmReceipt?orderId=XXXX    post请求
export function confirmReceiptApi (orderId) {
    return baseRequest.baseRequest(`api/order/confirmReceipt?orderId=${orderId}`, 'post')
}

// 搜索订单 /api/order/search get
export function searchOrderApi (data) {
    return baseRequest.baseRequest('api/order/search', 'get', data)
}
// 查询订单搜索关键字列表 /api/order/keywords
export function getOrderKeywordsApi () {
    return baseRequest.baseRequest('api/order/keywords', 'get')
}

// 删除订单搜索关键字
// /api/order/keywords/delete  post请求
export function deleteOrderKeywordsApi (data) {
    return baseRequest.baseRequest('api/order/keywords/delete', 'post', JSON.stringify(data))
}



/**
 * 订单申请售后
 */

// 点击商品 查看选中商品详情 售后详情/api/aftersales/order/queryApplyRefundPageInfo    post请求  
export function getAfterSalesOrderApi (data) {
    return baseRequest.baseRequest('api/aftersales/order/queryApplyRefundPageInfo','post',  JSON.stringify(data))
}
// 申请售后/api/aftersales/order/create post请求   提交售后申请
export function createAfterSalesOrderApi (data) {
    return baseRequest.baseRequest('api/aftersales/order/create', 'post', JSON.stringify(data))
}

// 获取申请售后后 售后详情  /api/aftersales/order/detail/{afterSalesId}    get请求
export function getAfterSalesOrderDetailApi (afterSalesId) {
    return baseRequest.baseRequest(`api/aftersales/order/detail/${afterSalesId}`, 'get')
}
// 取消售后申请 /api/aftersales/order/cancelApply/{afterSalesId}   post请求
export function cancelAfterSalesOrderApi (afterSalesId) {
    return baseRequest.baseRequest(`api/aftersales/order/cancelApply/${afterSalesId}`, 'post')
}
// 查看当前订单 是都已售后 是否可以售后 /api/aftersales/order/validity/{afterSalesId}  get请求
export function getAfterSalesOrderValidityApi (orderId) {
    return baseRequest.baseRequest(`api/aftersales/order/validity/${orderId}`, 'get')
}
// 删除售后列表中记录 /api/aftersales/order/delete/{afterSalesId}  post请求
export function deleteAfterSalesOrderApi (afterSalesId) {
    return baseRequest.baseRequest(`api/aftersales/order/delete/${afterSalesId}`, 'post')
}
// 售后历史 /api/aftersales/order/history/{afterSalesId}   get 请求
export function getAfterSalesOrderHistoryApi (afterSalesId) {
    return baseRequest.baseRequest(`api/aftersales/order/history/${afterSalesId}`, 'get')
}

/**
 * 下单后修改自提点
 */

// 修改自提点 /api/order/modifySelfPick?orderId=xxx&selfPickId=xxx  post请求
export function modifySelfPickApi (orderId,selfPickId) {
    return baseRequest.baseRequest(`api/order/modifySelfPick?orderId=${orderId}&selfPickId=${selfPickId}`, 'post')
}




/**
 * 服务商品结算
 *  */ 
// export function queryServiceSettleInfoApi (productId,productAttrValueId) {
//     return baseRequest.baseRequest(`api/order/queryServiceSettleInfo/${productId}/${productAttrValueId}`, 'get')
// }
/**
 * 
 * @param {服务商品} data 
 * @returns 
 */
// 服务商品结算详情  /api/order/queryServiceSettleInfo	  服务商品结算详情   post请求
export function queryServiceSettleInfoApi (data) {
    return baseRequest.baseRequest('api/order/queryServiceSettleInfo', 'post', JSON.stringify(data))
}

// 生成服务商品订单 /api/order/createServiceOrder  post
export function createServiceOrderApi (data) {
    return baseRequest.baseRequest('api/order/createServiceOrder', 'post', JSON.stringify(data))
}
